<?php
header('content-type:text/html;charset=utf-8');
//匹配正整数
$subject=0;
$pattern='#^[1-9]\d*$#';
//匹配手机号
$subject='1863557961s';
//13/14/15/18
$pattern='#^(?:13|14|15|18)\d{9}$#';
//匹配电话号码010-88541234 57857123 0451-5787512
$subject='010-12345678';
// $subject='12345678';
// $subject='0451-1231231';
$pattern='#^(\d{4}|\d{3})?-?(\d{8}|\d{7})$#';
//匹配身份证
$subject='230122197812234x';
$pattern='#^(\d{15}|\d{17})[0-9xX]$#';
//匹配中文
$subject='king';
$pattern='#[\x{4e00}-\x{9fa5}]#u';
if(preg_match($pattern,$subject,$match)){
    echo '合法<br/><pre>';
    print_r($match);
    echo '</pre>';
}else{
    echo '不合法';
}
//匹配ip地址，202.123.56.1  127.0.0.1  255.255.255.0


